using UnityEngine;

public class DailyPrizeLayer : MonoBehaviour
{
	public UISprite coinSprite;

	public UILabel collectText;

	public UILabel coinLabel;

	public UISprite button;

	public UILabel tomorrowCoins;

	public ParticleSystem particles;

	private void Awake()
	{
	}

	private void OnEnable()
	{
		Ads.instance.hideBanner(true);
		UpdateView();
		particles.Play();
	}

	private void OnDisable()
	{
		Ads.instance.hideBanner(false);
		particles.Stop();
	}

	private void UpdateView()
	{
		WalletManager walletManager = GGPlayerSettings.instance.walletManager;
		button.spriteName = ((!walletManager.isDailyCoinsActive()) ? "btn-red" : "btn-green");
		collectText.text = ((!walletManager.isDailyCoinsActive()) ? ("Active in " + GGFormat.FormatTimeSpan(walletManager.TimeTillDailyCoinsActive())) : "Click to collect");
		DailyPrizesConfig.Prize prize = walletManager.CurrentPrize();
		DailyPrizesConfig.Prize prize2 = walletManager.NextPrize();
		coinSprite.spriteName = prize.spriteName;
		coinLabel.text = "$" + GGFormat.FormatWinnings(prize.prize);
		tomorrowCoins.text = "$" + GGFormat.FormatWinnings(prize2.prize);
	}

	public void OnClick()
	{
		WalletManager walletManager = GGPlayerSettings.instance.walletManager;
		if (walletManager.isDailyCoinsActive())
		{
			DailyPrizesConfig.Prize prize = walletManager.CurrentPrize();
			walletManager.CollectDailyCoins();
			UIDialog.instance.ShowOk("Won " + coinLabel.text, "You won " + coinLabel.text + "! Return tomorrow for " + tomorrowCoins.text + "!", "Ok", delegate
			{
				NavigationManager.instance.Pop();
				NavigationManager.instance.Pop();
			});
		}
		else
		{
			NavigationManager.instance.Pop();
		}
	}
}
